// pages/order/order.js
var app = getApp();
var shipping_status = 0;
Page({

  data: {
    isnull: false
  },
  onLoad: function (options) {
    var that = this

    wx.request({
      url: app.globalData.host + 'index.php/api/goods/findorder?admin_id=' + app.globalData.admin_id + '&openid=' + app.globalData.openid,
      method: "POST",
      success: function (e) {
        if (e.data == '') {
          that.setData({
            isnull: true
          })
        } else {
          that.setData({
            order: e.data.data.filter(that.filterHeaderCatids),
            isnull: false
          })
          if (that.data.order.length == 0) {
            that.setData({
              isnull: true
            })
          }
        }

      }
    })

    app.getUserInfo(function (userInfo) {
      that.setData({
        userInfo: userInfo
      })
    })
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.share,
      path: 'pages/index/index'
    }
  },
  filterHeaderCatids: function (e) {
    return (!e.goods_id)
  },
  confirm: function (e) {
    console.log(e)
    var that = this
    wx.request({
      url: 'https://xcxu.we-fs.com/index.php/api/goods/confirm?admin_id=' + app.globalData.admin_id + '&id=' + e.currentTarget.dataset.id,
      success: function (res) {
        wx.showToast({
          title: '收货成功',
          icon: 'success',
          duration: 2000
        })
        console.log(that.data.list)
      }
    });
  },
})